package com.example.deferredResultDemo.service;

import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;

public class Dog {

    private int age;
    private String name;

    public void setAge(int age) {
        this.age = age;
        System.out.println(age);
    }

    public boolean setName(String name) {
        System.out.println(name);
        return true;
    }

    public static void main(String[] args) {
        ConcurrentHashMap<String, Consumer<String>> consumerMap = new ConcurrentHashMap<>();
        Dog dog1 = new Dog();
        consumerMap.putIfAbsent("tom", dog1::setName);
        consumerMap.get("tom").accept("111");  // dog name is 111

        ConcurrentHashMap<String, Dog> dogMap = new ConcurrentHashMap<>();
        Dog dog2 = new Dog();
        dogMap.putIfAbsent("tom", dog2);
        dogMap.get("tom").setName("111");  // dog name is 111

    }




}
